﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PlusiMinus
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Match match1Dod = Regex.Match(textBox1.Text, "^[0-9]+$");
            Match match1Ujemna = Regex.Match(textBox1.Text, "^-[0-9]+$");
            Match match2Dod = Regex.Match(textBox2.Text, "^[0-9]+$");
            Match match2Ujemna = Regex.Match(textBox2.Text, "^-[0-9]+$");
            if (match1Dod.Success || match1Ujemna.Success)
            {
                if( match2Dod.Success || match2Ujemna.Success)
            {
                double a = Double.Parse(textBox1.Text);
                double b = Double.Parse(textBox2.Text);
                if (b > -35 && b < 2) // Ograniczenie wersji demo
                {
                    double wynik = a + b;
                    label1.Text = wynik.ToString();
                }
                else
                {
                    Form3 f3 = new Form3();
                    f3.Show();
                }
            }
            else
            {
                Form2 f2 = new Form2();
                f2.Show();
            }
            }
            else
            {
                Form2 f2 = new Form2();
                f2.Show();
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            Match match1Dod = Regex.Match(textBox1.Text, "^[0-9]+$");
            Match match1Ujemna = Regex.Match(textBox1.Text, "^-[0-9]+$");
            Match match2Dod = Regex.Match(textBox2.Text, "^[0-9]+$");
            Match match2Ujemna = Regex.Match(textBox2.Text, "^-[0-9]+$");
            if (match1Dod.Success || match1Ujemna.Success)
            {
                if( match2Dod.Success || match2Ujemna.Success)
            {
                
                double a = Double.Parse(textBox1.Text);
                double b = Double.Parse(textBox2.Text);
                if (-35 < b || b > 2) // Ograniczenie wersji demo
                {
                    double wynik = a - b;
                    label1.Text = wynik.ToString();
                }
                else
                {
                    Form2 f3 = new Form2();
                    f3.Show();
                }
            }
            else
            {
                Form2 f2 = new Form2();
                f2.Show();
            }
            }
            else
            {
                Form2 f2 = new Form2();
                f2.Show();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        //int f(int x) {
         //   return 2 * x + 1;
        //}

    }
}
